package com.gopay.checkorder.dao;

import java.util.Date;
import java.util.List;

import com.gopay.common.base.dao.BaseDAO;
import com.gopay.common.domain.bank.BankOrder;
import com.gopay.common.domain.bank.CheckOrderFailLog;
import com.gopay.common.domain.bank.CheckOrderLog;

/**
 * 银行流水DAO
 * 
 * @BankOrderDAO.java
 * @author yaobo
 * @2013-2-26 下午01:51:35 www.gopay.com.cn Inc.All rights reserved.
 */
public interface BankOrderDAO extends BaseDAO<BankOrder, String> {
	public List<BankOrder> getCheckOrder(Date date, int pageIndex, int pageSize);
	
    public int getCheckOrderCount(Date date);
    /**
     * 根据银行订单号获取银行流水
     * 
     * @param gopayOutOrderId
     *            银行订单号
     * @return
     */
    public BankOrder getByGopayOutOrderId(String gopayOutOrderId);
    /**
     * 根据国付宝订单号获取银行流水
     * 
     * @param gopayOrderId
     *            国付宝订单号
     * @return
     */
    public BankOrder getByGopayOrderId(String gopayOrderId);

    /**
     * 将状态为进行中的银行流水锁定
     * 
     * @param bankOrder
     *            银行流水
     * @return
     */
    public int lock(BankOrder bankOrder);
    
    /**
     * 解锁银行流水记录
     * 
     * @param bankOrder
     *            银行流水
     * @return
     */
    public int unlock(BankOrder bankOrder);
    
    /**
     * 更新对账次数
     * 
     * @param bankOrder
     *            银行流水
     * @return
     */
    public int updateTotalCheckTimes(BankOrder bankOrder);
    
    /**
     * 银行流水置为失败，状态为[失败]
     * 
     * @param bankOrder
     *            银行流水
     * @return
     */
    public int updateCheckFail(BankOrder bankOrder);
    
    /**
     * 银行流水置为失败，状态为[入账失败]
     * 
     * @param bankOrder
     *            银行流水
     * @return
     */
    public int updateEnterAccountFail(BankOrder bankOrder);
    
    /**
     * 银行流水状态置为[作废]
     * 
     * @param bankOrder
     * @return
     */
    public int updateCancel(BankOrder bankOrder);

    /**
     * 银行流水置为成功，状态为[成功]
     * 
     * @param bankOrder
     * @param bankOrderStatus
     * @return
     */
    public int updateCheckSuccess(BankOrder bankOrder, String bankOrderStatus);
    
    
    /**
     * 新增对账日志记录
     * @param checkOrderLog
     * @return
     */
    public void insertCheckOrderLog(CheckOrderLog checkOrderLog);
    
    /**
     * 更新对账日志记录
     * @param checkOrderLog
     * @param respcode
     * @param checktime
     * @param totalCheckTime
     * @return
     */
    public int updateCheckOrderLog(CheckOrderLog checkOrderLog,String respcode,Date checktime,int totalCheckTime);
    
    /**
     * 新增对账报警记录
     * @param checkOrderFailLog
     */
    public void insertCheckOrderFailLog(CheckOrderFailLog checkOrderFailLog);
    
    /**
     * 查询对账报警表
     * @return
     */
    public List getCheckOrderFailLog();

	public List<BankOrder> getGopayOrders(String bank, String date);
	
	/**
     * 银行流水置为金额校验不符
     * 
     * @param bankOrder
     *            银行流水
     * @return
     */
    public int updateAmountError(BankOrder bankOrder);

    /**
     * 修改bankorderId
     * @param outOrderId 主键
     * @param payMsgId 银行返回流水号
     * @return
     */
	public int updateBankOrderId(String outOrderId, String payMsgId);

    /**
     * hougn 2017-09-26
     * 根据银行（bank_code）进行分组，查询日期（transTime）最新的记录，
     * 查询十分钟之内数据，失败数大于等于failCount
     * @param failCount
     * @return
     */
    List getCheckOrderFailLog(String failCount);
}
